-- Create table `${table.tableName}`
CREATE TABLE `${table.tableName}` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
<#if table.columns??>
<#list table.columns as column>
  `${column.columnName}` <#if column.columnType??>${DDLTemplateUtil.getDbTypeForColumn(column.columnType, schema.dbType)!column.columnType}<#else>${column.columnType!"VARCHAR"}</#if><#if column.columnLength?? && column.columnLength gt 0>(<#if column.columnPrecision?? && column.columnPrecision gt 0>${column.columnPrecision}<#if column.columnScale?? && column.columnScale gt 0>,${column.columnScale}</#if><#else>${column.columnLength}</#if>)</#if> COMMENT '${column.columnComment!"字段注释"}'<#if column_has_next>,</#if>
</#list>
</#if>
<#if table.constraints??>
<#list table.constraints as constraint>
<#if constraint.constraintType?? && constraint.constraintType == "PRIMARY_KEY">
  ,CONSTRAINT `${constraint.constraintName!"PK_" + table.tableName?upper_case}` PRIMARY KEY (<#if constraint.columnList??>${constraint.columnList?join(",", "(col) -> \"`\" + col.columnName + \"`\"")}</#if>)
<#elseif constraint.constraintType?? && constraint.constraintType == "FOREIGN_KEY">
  ,CONSTRAINT `${constraint.constraintName!"FK_" + table.tableName?upper_case}` FOREIGN KEY (<#if constraint.columnList??>${constraint.columnList?join(",", "(col) -> \"`\" + col.columnName + \"`\"")}</#if>) REFERENCES ???
<#elseif constraint.constraintType?? && constraint.constraintType == "UNIQUE">
  ,CONSTRAINT `${constraint.constraintName!"UK_" + table.tableName?upper_case}` UNIQUE (<#if constraint.columnList??>${constraint.columnList?join(",", "(col) -> \"`\" + col.columnName + \"`\"")}</#if>)
<#elseif constraint.constraintType?? && constraint.constraintType == "CHECK">
  ,CONSTRAINT `${constraint.constraintName!"CK_" + table.tableName?upper_case}` CHECK (???)
</#if>
</#list>
</#if>
  ,PRIMARY KEY (`id`)
) COMMENT='${table.tableComment!"表注释"}';